package cn.xopencode.recordservice.dal.mysql.mapper.sf6machine;

import cn.xopencode.recordservice.dal.mysql.dataobject.pdroom.PdRoomDeptRelDO;
import cn.xopencode.recordservice.dal.mysql.dataobject.sf6machine.Sf6MachineRecordEmpRelDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface Sf6MachineRecordEmpRelMapper extends BaseMapper<Sf6MachineRecordEmpRelDO> {

    /**
     * 批量插入。因为 MyBaits Plus 的批量插入是基于 Service 实现，所以只好写 XML
     *
     * @param empRelDOList 数组
     */
    int insertList(@Param("empRelDOList") List<Sf6MachineRecordEmpRelDO> empRelDOList);

    default List<Sf6MachineRecordEmpRelDO> selectListByRecordCode(String recordCode){
        return selectList(new QueryWrapper<Sf6MachineRecordEmpRelDO>().eq("record_code", recordCode).eq("is_manager", false));
    }

    default List<Sf6MachineRecordEmpRelDO> selectManagerByRecordCode(String recordCode){
        return selectList(new QueryWrapper<Sf6MachineRecordEmpRelDO>().eq("record_code", recordCode).eq("is_manager", true));
    }

    default int deleteByRecordCode(String recordCode){
        return delete(new QueryWrapper<Sf6MachineRecordEmpRelDO>().eq("record_code", recordCode));
    }
}
